BaseReporter   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
eloc 14
dl 0
loc 25
rs 10
c 0
b 0
f 0

4 Functions

Rating   Name   Duplication   Size   Complexity  
A constructor 0 3 1
A getHash 0 3 1
A _init 0 1 1
A _build 0 13 3
1
import dP from 'dot-prop';
2
import { findGroup } from './utils';
3
4
export default class BaseReporter {
5
    constructor(file) {
6
        this.file = file;
7
    }
8
9
    _init() {}
10
11
    _build(actions, { groupBy = [] } = {}) {
12
        const map = new Map();
13
        const groups = {};
14
15
        for (const a of actions) {
16
            const groupValues = groupBy.map(key => dP.get(a, key));
17
18
            findGroup.call(this, groups, groupValues, a.id);
19
            map.set(a.id, a);
20
        }
21
22
        return { groups, map };
23
    }
24
25
    getHash(action) {
26
        return action.id;
27
    }
28
}
29